local skel = fk.CreateSkill{
    name = "kt_ls__zhangying",
}

local KleeU = require "packages/klee_xy_I/utility/k_utility"

Fk:loadTranslationTable{
  ["kt_ls__zhangying"] = "丈缨",
  [":kt_ls__zhangying"] = "每轮限一次，当一张【杀】的路径经过你而指定主公时，你可以改变目标至你，且由少到多的重铸手牌直到获得了【闪】，"..
  "使用者[由多到少的]询问其他角色弃置一张牌&lt;助战-多结算一次&gt;。",
  ["#kt_ls__zhangying_1"] = "由少到多的重铸手牌直到获得了【闪】（目前 %arg 张）",
  ["#kt_ls__zhangying_2"] = "弃置一张牌&lt;助战-多结算一次&gt;",
}

skel:addEffect(fk.TargetSpecifying,{
  can_trigger = function (self, event, target, player, data)
    local room = player.room
    local load = room:getLord()
    if player:hasSkill(skel.name) and data.card.trueName == "slash" and player:usedSkillTimes(skel.name,Player.HistoryRound) and
    data.firstTarget and load and table.contains(data.use.tos, load) then
      local list = KleeU.PlayerInRoad(player,data.from,load)
      if #list > 0 then
        return true
      end
    end
  end,
  on_use = function (self, event, target, player, data)
    local room = player.room
    data.use.tos = {player}
    --重铸牌
    local i = 1
    while i <= #player:getCardIds("h") do
      local _,cid = room:askToChooseCardsAndPlayers(player,{
        min_num = 0,
        max_num = 0,
        min_card_num = i,
        max_card_num = i,
        targets = {},
        skill_name = skel.name,
        cancelable = false,
        pattern = ".|.|.|hand",
        prompt = "#kt_ls__zhangying_1:::"..i,
      })
      local card = room:recastCard(cid,player,skel.name)
      if table.find(card,function (c) return Fk:getCardById(c).name == "jink" end) then break end
      i = i + 1
    end
    for _,p in ipairs(room:getOtherPlayers(data.from)) do
      if not table.contains(data.use.tos, p) then
        local _,cid = room:askToChooseCardsAndPlayers(p,{
          min_num = 0,
          max_num = 0,
          min_card_num = 1,
          max_card_num = 1,
          targets = {},
          skill_name = skel.name,
          cancelable = true,
          prompt = "#kt_ls__zhangying_2",
        })
        if #cid > 0 then
          room:throwCard(cid,skel.name,p)
          data.use.additionalEffect = data.use.additionalEffect + 1
        end
      end
    end
  end,
})

return skel